package cn.mulanbay.admin.api.persistent.service;

import cn.mulanbay.persistent.entity.UserWxpayInfo;
import cn.mulanbay.persistent.mapper.UserWxpayInfoMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author fenghong
 * @since 2022-02-06
 */
@Service
public class UserWxpayInfoService extends ServiceImpl<UserWxpayInfoMapper, UserWxpayInfo> {

    @Autowired
    UserWxpayInfoMapper userWxpayInfoMapper;

    public UserWxpayInfo getByUserId(Long userId,String appId){
        return userWxpayInfoMapper.getByUserId(userId,appId);
    }

    public UserWxpayInfo getByOpenId(String appId,String openId){
        return userWxpayInfoMapper.getByOpenId(appId,openId);
    }

    public void saveOrUpdateInfo(UserWxpayInfo uwi){
        if(uwi.getId()==null){
            userWxpayInfoMapper.insert(uwi);
        }else {
            userWxpayInfoMapper.updateById(uwi);
        }
    }
}
